package it.polimi.swKnights.SWIMv2.ejb.entityBeans;

import java.io.Serializable;
import javax.persistence.*;

/**
 * Entity implementation class for Entity: FriendshipRequest
 * 
 */
@Entity
@IdClass(FriendshipRequestPk.class)
public class FriendshipRequest implements Serializable
{
	@Id
	@Column(name = "requestedName", insertable = false, updatable = false)
	private String requestedName;

	@Id
	@Column(name ="applicantName", insertable = false, updatable = false)
	private String applicantName;
	
	@ManyToOne
	@JoinColumn(name = "applicantName", insertable = false, updatable = false)
	private RegisteredUser applicant; 
	
	@ManyToOne
	@JoinColumn(name = "requestedName", insertable = false, updatable = false)
	private RegisteredUser requested;

	private boolean refused;

	private boolean direct;

	private static final long serialVersionUID = 1L;

	/*
	 * Constructors
	 */

	public FriendshipRequest()
	{
		super();
	}

	public FriendshipRequest(RegisteredUser applicant,
			RegisteredUser requested, boolean direct)
	{
		this.requestedName = requested.getUserName();
		this.applicantName = applicant.getUserName();
		this.direct = direct;
		this.refused = false;
	}

	/*
	 * Getters and setters
	 */

	public boolean isRefused()
	{
		return refused;
	}

	public void setRefused(boolean refused)
	{
		this.refused = refused;
	}

	public boolean isDirect()
	{
		return direct;
	}

	public void setDirect(boolean direct)
	{
		this.direct = direct;
	}

}
